package com.cy.pj.notice.dao.impl;

import com.cy.pj.notice.dao.SysNoticeDao;
import com.cy.pj.notice.pojo.SysNotice;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;
import java.util.List;

//@Repository   //默认bean的名字为类名，然后首字母小写
public class SysNoticeDaoImpl implements SysNoticeDao {
    @Autowired
    private SqlSession sqlSession;  // sqlSessionTemplate 是线程安全的

    @Override
    public List<SysNotice> selectNotices(SysNotice notice) throws IOException {
        String namespace = this.getClass().getInterfaces()[0].getName();
        String elementId = Thread.currentThread().getStackTrace()[1].getMethodName();
        String statement = namespace+"."+elementId;
//        String statement = "com.cy.pj.notice.dao.SysNoticeDao.selectNotices";
        List<SysNotice> list = sqlSession.selectList(statement, notice);
        return list;
    }

    @Override
    public int deleteNotice(Long... id) {
        return 0;
    }

    @Override
    public int insertNotice(SysNotice notice) {
        return 0;
    }

    @Override
    public SysNotice selectById(Long id) {
        return null;
    }

    @Override
    public int updateNotice(SysNotice notice) {
        return 0;
    }
}
